package com.carpedil.test;

import com.carpedil.config.ApplicationContext;
import com.carpedil.dao.UserDao;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class AopXMLTest2 {
  @Test
  /** 通过XML文件获取容器 */
  public void testAop() {
    ClassPathXmlApplicationContext context =
        new ClassPathXmlApplicationContext("applicationContext.xml");
    UserDao userDao = context.getBean("userDao", UserDao.class);
    userDao.addUser();
  }

  @Test
  /** 通过配置类获取容器 */
  public void testAopConfig() {
    AnnotationConfigApplicationContext context =
        new AnnotationConfigApplicationContext(ApplicationContext.class);
    UserDao userDao = context.getBean("userDao", UserDao.class);
    userDao.addUser();
  }
}
